using System;
using System.Collections.Generic;
using System.Reflection;

namespace IQIGame.Onigao.GamePlay.Editors
{
    public static class TypeExtends
    {
        public static List<Type> GetSubTypes(this Type type, List<Type> results = null)
        {
            List<Type> subTypes = results ?? new List<Type>();
            Type[] allTypes = Assembly.GetAssembly(type).GetTypes();
            foreach (Type t in allTypes)
            {
                if (t != type && t.IsSubclassOf(type))
                {
                    subTypes.Add(t);
                }
            }
            return subTypes;
        }
    }
}
